1. Field of the Present Invention
The present invention generally relates to error detection mechanisms in electronic systems and more particularly to a method and system that utilize CRC codes for portions of a file to verify file integrity.
2. History of Related Art
The use of CRC codes to verify the integrity of digital information is well known. CRC codes are typically generated at the time a file is generated. When the file is later transferred or copied to a second location, the CRC code is used to verify that copied file is a duplicate of the original file. The prior art uses of CRC codes do not, however, address the problem of verifying the transferred data before committing the transferred data to a destination medium. Typically in the prior art, the CRC codes are verified only after the transferred file is stored in its destination. This drawback is significant, especially in file transfer applications, such as the updating of a system""s microcode, in which the accuracy of the transferred file is critical and, in which, the data, once committed, cannot be trivially overwritten by simply initiating another transfer. Moreover, existing CRC applications are not typically optimized to recognize that files are routinely transferred as a sequence of portions or sectors. Sector transfers can be utilized to provide earlier feedback for error detection circuitry and can help pinpoint the source of the errors. Jedwab (U.S. Pat. No. 5,778,013) for example utilizes generated CRC codes on a sector by sector basis coupled with a CRC code compilation technique to facilitate error checking in a transfer mechanism in which multiple messages are interspersed on the transfer medium. The sector CRCs of Jedwab are tagged and later summed using a summing technique to produce a final CRC code for each message. Unfortunately, the Jedwab patent and others that address CRC codes in the context of sectored transfers assume (1) that the transmit side generates the first pass CRC codes and (2) that, if an error is detected, the file can simply be retransmitted or resent. In addition, the prior art does not typically consider the application of CRC codes for use in embedded applications where system resources are exceedingly scarce. Without sufficient memory, for example, to store each sector of a file until the entire file""s CRC code is known, the system must essentially decide whether to keep the sector data without the luxury of being able to wait until the file is completely transferred to verify the CRC code. With the proliferation of the use of error prone file transfer media, it would be highly desirable to implement a practical and elegant solution to these problems.
Broadly speaking, the invention contemplates a method of verifying the integrity of a file transferred as a plurality of sectors. During a first pass transfer of a sectored file, first pass sector CRC codes are generated for each sector. These first pass sector CRC codes are stored in a system memory. In the preferred embodiment, the sector data is not committed to the destination medium. During a second pass transfer, second pass CRC codes are generated for each sector. The second pass CRC codes are compared to the first pass CRC codes for corresponding sectors. If the second pass CRC code matches the first pass CRC code, the sector is committed to the destination medium. In the preferred embodiment, the second pass transfer is retried if the first and second pass CRC codes do not match. The CRC sector values for an initial sector of the file are preferably generated from a predefined seed. Each successive CRC sector value is then preferably generated from the preceding sector""s CRC code such that the sector CRC code of the last sector comprises a final CRC code of the file. In the preferred embodiment, the second pass transfer is aborted if the first pass final CRC code varies from an embedded CRC code in the file. In one embodiment, the file comprises microcode and sectors are stored by programming a flash memory or other suitable non-volatile storage device.
In another embodiment, the invention contemplates the updating or reprogramming of a system""s microcode in which, prior to the transfer process, a final CRC code is embedded in a header of a microcode file on a source medium. In a first pass transfer, the microcode file is transferred to the system with a plurality of sector transfers. First pass sector CRC codes are generated for each segment transferred during the first pass transfer and stored in memory. In one embodiment, the first pass sector CRC code of the last sector of the microcode is the first pass final CRC code for the microcode. The first pass final CRC code is then compared to the embedded CRC code in the file header. Responsive to a match between the embedded final CRC code and the first pass final CRC code, the microcode file is then transferred again to the system in a second transfer to the system with a plurality of sector transfers. Second pass sector CRC codes are generated for each sector transferred during the second pass transfer and compared to each second pass sector CRC code with the sector""s corresponding first pass sector CRC code. Responsive to detecting a match between a first pass sector CRC code and a second pass sector CRC code, the sector is stored in a non-volatile storage of the system. The source medium may comprise a diskette, the hard disk of a server to which the system connected via a network, or other suitable media
The invention further contemplates a system including means for receiving file sectors, means for generating first pass sector CRC codes for each file sector received during a first pass file transfer, means for storing each first pass sector CRC code in memory, means for extracting a final CRC code embedded in the file, means for comparing the first pass sector CRC code of the final sector to the embedded final CRC code, means, responsive to the comparing means, for initiating a second pass transfer of the file sectors, means for generating second pass sector CRC codes for each sector received during the second pass transfer and for comparing the second pass sector CRC codes to respective first pass sector CRC codes; and means for storing sectors if their second pass sector CRC code matches their first pass CRC code for the sector.